package com.plugin.storage.base;

import com.google.common.base.Strings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class SdkContext implements Cloneable {

    private static final Logger LOGGER = LoggerFactory.getLogger(SdkContext.class);

    private String uploadEndpoint;

    private String accessEndpoint;

    private String tokenEndpoint;

    private String bucket;

    private String accessKeyId;

    private String accessKeySecret;

    private String cdnKey;

    private String region;

    private String roleArn;

    private String roleSessionName;

    private int timeout;

    private String alias;

    public static SdkContext create() {
        return new SdkContext();
    }

    public String getUploadEndpoint() {
        return uploadEndpoint;
    }

    public SdkContext setUploadEndpoint(String uploadEndpoint) {
        this.uploadEndpoint = uploadEndpoint;
        return this;
    }

    public String getAccessEndpoint() {
        return accessEndpoint;
    }

    public SdkContext setAccessEndpoint(String accessEndpoint) {
        if (Strings.isNullOrEmpty(accessEndpoint)) {
            return this;
        }
        if (accessEndpoint.endsWith("/")) {
            accessEndpoint = accessEndpoint.substring(0, accessEndpoint.length() - 1);
        }
        this.accessEndpoint = accessEndpoint;
        return this;
    }

    public String getTokenEndpoint() {
        return tokenEndpoint;
    }

    public SdkContext setTokenEndpoint(String tokenEndpoint) {
        this.tokenEndpoint = tokenEndpoint;
        return this;
    }

    public String getBucket() {
        return bucket;
    }

    public SdkContext setBucket(String bucket) {
        this.bucket = bucket;
        return this;
    }

    public String getAccessKeyId() {
        return accessKeyId;
    }

    public SdkContext setAccessKeyId(String accessKeyId) {
        this.accessKeyId = accessKeyId;
        return this;
    }

    public String getAccessKeySecret() {
        return accessKeySecret;
    }

    public SdkContext setAccessKeySecret(String accessKeySecret) {
        this.accessKeySecret = accessKeySecret;
        return this;
    }

    public String getCdnKey() {
        return cdnKey;
    }

    public SdkContext setCdnKey(String cdnKey) {
        this.cdnKey = cdnKey;
        return this;
    }

    public String getRegion() {
        return region;
    }

    public SdkContext setRegion(String region) {
        this.region = region;
        return this;
    }

    public String getRoleArn() {
        return roleArn;
    }

    public SdkContext setRoleArn(String roleArn) {
        this.roleArn = roleArn;
        return this;
    }

    public String getRoleSessionName() {
        return roleSessionName;
    }

    public SdkContext setRoleSessionName(String roleSessionName) {
        this.roleSessionName = roleSessionName;
        return this;
    }

    public int getTimeout() {
        return timeout;
    }

    public SdkContext setTimeout(int timeout) {
        this.timeout = timeout;
        return this;
    }

    public String getAlias() {
        return alias;
    }

    public SdkContext setAlias(String alias) {
        this.alias = alias;
        return this;
    }

    @Override
    public SdkContext clone() {
        try {
            return ((SdkContext) super.clone());
        } catch (CloneNotSupportedException e) {
            return SdkContext.create();
        }
    }
}
